<!--
 * @Date: 2025-02-13 09:55:02
 * @Author: LiSong
 * @LastEditors: LiSong
 * @LastEditTime: 2025-03-06 10:19:59
 * @Description: 点击事件
-->
<template>
  <div>
    <el-button round size="small" type="primary" :plain="!existContent"
      @click="dialogOpen">编辑</el-button>
    <CodeStudioDialog ref="dialogRef" :="dialogAttrs" @confirm="dialogConfirm"/>
  </div>
</template>

<script setup>
import { reactive, ref, watch, defineAsyncComponent, computed } from 'vue';
import CodeStudioDialog from '@hp/comps/dialog/src/CodeStudioDialog.vue'

const emits = defineEmits(['update:modelValue'])
const props = defineProps({
  schema: { type: Object },
  config: { type: Object },
  modelValue: { type: String, default: '' },
  codeConfig: { type: Object, default: {} },
})

const dialogRef = ref()
const dialogAttrs = reactive({
  title: `${props.config.label}-内容编辑`,
  codeType: 'func',
  eventName: props.config.field,
  eventParams: ['data', 'params'],
})
const existContent = computed(() => {
  return props.modelValue
})
const dialogOpen= () => {
  dialogRef.value.handleOpen(props.schema[props.config.field])
}
const dialogConfirm = (content) => {
  emits('update:modelValue', content)
}

watch(
  () => props.modelValue,
  (nv) => {

  },
  { deep: true, immediate: true }
)

</script>

<style lang="scss" scoped>

</style>